<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
         html,body {
             width: 100%;
             height: 100%;
             background: url(./img/bj.webp) no-repeat 0 0/100% 100%;
         }
         #box1 {
             width: 150px;
             height: 50px;
             border: 5px solid green;
             position: absolute;
             left: 0;
             top: 0;
         }
         #sp1 {
             width: 1%;
             height: 100%;
             display: block;
             background: red;
         }
         #box2 {

            font: 100px/150px "";
            color: red;
            position: absolute;
            left: 50%;
            top: 50%;
            transform: translateX(-50%) translateY(-50%);
            display: none;
         }
    </style>
</head>
<body>
    <div id="box1">
        <span id="sp1"></span>
    </div>
    <div id="box2">GIME OVER!!!</div>
    <script>
        function random(min,max){
            return Math.floor(Math.random()*(max-min+1)+min);
        }
        function createxx(){
            var imgobj = document.createElement('img');
            imgobj.src = 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fbbs.076299.com%2Fattachment13%2Fmonth_0910%2F0910130926400bc174a26bcf91.gif%3F48&refer=http%3A%2F%2Fbbs.076299.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1642928903&t=5483d8403f9237ed966f41d9cb108aae'
            var w = window.innerWidth || document.documentElement.clientWidth;
            var h = window.innerHeight || document.documentElement.clientHeight;
            var xxsize = random(60,70);
            imgobj.width = xxsize;
            imgobj.height = xxsize;
            imgobj.style.position='absolute';
            imgobj.style.left = random(0,w-xxsize) +'px';
            imgobj.style.top = random(0,h-xxsize) +'px';
            document.body.append(imgobj);
            num-=20;
            if(num<0)num=0
            sp1obj.style.width = num + 'px';
            if(num==0){
                box2obj.style.display = 'block';
                clearInterval(t);
            }
        }
        function removexx(){
            document.onclick=function(evt){
            if(num>0){
            var e = evt || window.event;
            var target = e.target || e.srcElement
                if(target.nodeName === 'IMG'){
                    document.body.removeChild(target);
                    num+=20;
                    if(num>150)num=150
                    sp1obj.style.width = num + 'px';
                }
            }
            }
        }
        var num = 150;
        var sp1obj = document.querySelector('#sp1');
        var box2obj = document.querySelector('#box2');
        sp1obj.style.width = 150 +'px';
        var t = setInterval(createxx,2000);
        removexx()
    </script>
</body>
</html>